<%@page contentType="text/html" language="java" import="com.compuvest.web.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@ taglib uri="/WEB-INF/tld/head.tld" prefix="head" %>
<%@ taglib uri="/WEB-INF/tld/bottom.tld" prefix="bottom" %>

<jsp:useBean id="sb" class="MySQL" scope="application"/>
<jsp:useBean id="basket" class="Basket" scope="session"/>
<%
    Customer cust = basket.getCustomer();
    if(cust == null) {
	response.sendRedirect(application.getInitParameter("https") + "CustomerForm.jsp");
	return;
    }
    java.text.DecimalFormat prf = new java.text.DecimalFormat("$###,##0.00");

    java.util.List<Order> orders = sb.getOrders(cust.getCustomerID());
%>
<html>
<%@include file="/incl/head.html" %>

<body>

<table style='height:100%;'>

<tr valign=top height=84>
 <td colspan=3>

<head:show />

 </td>
</tr>

<tr valign=top align=center>
 <td style="width:160px;">

<div class=cstitle>Orders History</div>
<hr width='90%'/>

<table width='80%' cellspacing=1 cellpadding=1 style='background:silver;font:bold 8.3pt Arial;height:18px;'>
 <tr height=26><td colspan=10 background="../images/tbg.png">&nbsp;</td></tr>
 <tr bgcolor=lightblue><th></th><th>Order #</th><th>Date</th><th>COD</th><th>Shipping</th><th>Delivery</th><th>WA Tax</th><th>Total</th><th>Tracking #</th></tr>
<%
    boolean bground = false;
    for(Order order : orders) {
%>
 <tr bgcolor=#ffff<%= (bground = !bground) ? "cf" : "ef" %> align=center>
  <td>
<%
	if(order.haveHistory()) {
%>
  <a href='<%= application.getInitParameter("https") + "OrderPrint.jsp" %>?oid=<%= order.getOrderID() %>'>Print</a>
<%
	}
%>
  </td>
  <td><%= order.getOrderNo() %></td>
  <td><%= order.getOrderDate() %></td>
  <td><%= "Y".equals(order.getCOD()) ? "COD" : "" %></td>
  <td><%= order.getShippingCost() == 0d ? "" : prf.format(order.getShippingCost()) %></td>
  <td><%= order.getShippingDesc() %></td>
  <td><%= order.getTaxCost() == 0d ? "" : prf.format(order.getTaxCost()) %></td>
  <td><%= prf.format(order.getGrandTotal()) %></td>
  <td>
<%
	java.util.ArrayList<Tracking> tracks = order.getTracking();
	if(tracks.size() != 0) {
	    for(Tracking track : tracks) {
%>
  <%= track.getShippingCompany().length() == 0 ? "" : track.getShippingCompany() + ": " %><%= track.getStatusShort() %><br/>
<%
	    }
	}
	else {
%>
 Processing...
<%
	}
%>
  </td>
 </tr>
<%
    }
%>
</table>

<hr width='90%'/>
<br/>

 </td>

</tr>

<tr height=35>
 <td colspan=3>

<bottom:show />

 </td>
</tr>

</table>

</body>
<%@ include file="./incl/tracking.incl" %>
</html>
